import { getResource } from '@/api/resource'
import { ref } from 'vue'

/**
 * 项目示例-列表表头
 * Date 2023-5-25 09:33:56
 * 可选参数可参考：https://element-plus.org/zh-CN/component/table.html#table-column-属性
 */
//班次类型
const classTypeArr = ref<any>([])
//状态
const statusTypeArr = ref<any>([])
Promise.all([
  getResource('tcdm_class_type'),
  getResource('scheme_status'),
]).then(([res1, res2]) => {
  classTypeArr.value = res1.data.properties.meta
  statusTypeArr.value = res2.data.properties.meta
})
console.log(classTypeArr, statusTypeArr)
// 数据展示
export const exampleColumns = [
  {
    type: 'index',
    label: '序号',
    width: 80,
    align: 'center'
  },
  {
    prop: 'schemeName',
    label: '方案名称',
    align: 'center'
  },
  {
    prop: 'classType',
    label: '班次类型',
    align: 'center',
    width: 80,
    formatter: function (row: any, column: any, cellValue: any) {
      let dictName = ''
      classTypeArr.value.filter((item: any) => {
        if (cellValue == item.value) {
          dictName = item.label
        }
      })
      return dictName
    }
  },
  {
    prop: 'schemeModel',
    label: '排版模式',
    align: 'center',
    width:100,
    formatter: function (row: any, column: any, cellValue: any) {
      if(cellValue==1)  return '人员'
      if(cellValue==2)  return '班组'
    }
  },
  {
    prop: 'executor',
    label: '执行人',
    align: 'center',
    width: 110,
  },
  {
    prop: 'updateTime',
    label: '更新时间',
    sortable: 'custom',
    align: 'center',
  },
  {
    prop: 'status',
    label: '状态',
    sortable: 'custom',
    align: 'center',
    // width: 110,
    // formatter: function (row: any, column: any, cellValue: any) {
    //   let dictName = ''
    //   statusTypeArr.value.filter((item: any) => {
    //     if (cellValue == item.value) {
    //       dictName = item.label
    //     }
    //   })
    //   return dictName
    // }
  },
  {
    prop: 'action',
    label: '操作',
    align: 'center'
  }
]
